﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sustainalytics.ESGRatings.Primitives;

namespace Sustainalytics.ESGRatings.BusinessLogic.Computing
{
    public class ESGComputeContext
    {
        public Statistics MemoryStatistics => throw new NotImplementedException();

        private int _currentSetId;
        private Dictionary<int, ESGSet> _sets;


        public ESGComputeContext()
        {
            _sets = new Dictionary<int, ESGSet>();
        }


        private int NextId()
        {
            if (!_sets.Any())
            {
                _currentSetId = 0;
            }
            else
            {
                _currentSetId += 1;
            }

            return _currentSetId;
        }

        public int AddCompanySet(int companiesCount, int indicatorsCount, int clusterCount, byte[] esgHeads, byte[] disjunctClustersHeads, int disjunctClustersCount, byte[] disjunctClustersMap)
        {
            var setId = NextId();

            _sets.Add(setId, null);

            return setId;
        }


        public void AddMatrix(int setId, int matrixId, int weightsCount, float[] weightsMatrix, int profilesCount, byte[] profilesFlags)
        {   
        }

        public void AddUniverse(int setId, int universeId, int elementsCount, byte[] universe)
        {
        }

        public int[] CleanContext()
        {
            return _sets.Select(x => x.Key).ToArray();
        }

        public bool DeleteMatrix(int seId, int matrixId)
        {
            return true;
        }

        public bool DeleteReferenceUniverse(int id, int referenceUniverseId)
        {
            return true;
        }

        public bool DeleteSet(int setId)
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        public ESGRatings.Primitives.RatingsResult Ratings(int setId, int universeId, int matrixId, byte filter, int[] groupByHeads, bool returnIndicatorsRatings, bool returnAggregatedWeights, bool returnWeights, bool isDefaultWeightMatrix = false)
        {
            throw new NotImplementedException();
        }

        public GovernanceRatingsResult Ratings(int setId, int matrixId, bool includeWeightedScores, bool includeWeights)
        {
            throw new NotImplementedException();
        }

        public void SetAttributes(int setId, int elementsCount, byte[] attributes)
        {
        }

        public void SetAttributes(int id, int companiesNo, int attributesTypesCount, int[] regionGroupArray, int regionGroupsCount, int[] peerGroupArray, int peerGroupsCount)
        {
        }

        public void SetCombinationModifiers(int id, int matrixInternalId, int weightsCount, float[] weightData)
        {
            throw new NotImplementedException();
        }

        public void SetCompanyScores(int setId, int companiesNo, float[] scoresData, float[] weights)
        {
        }

        public void SetIndicators(int setId, int companiesCount, int indicatorsCount, float[] indicatorScores)
        {
        }

        public void SetIssueWeights(int id, int matrixInternalId, int weightsCount, float[] weightData)
        {
            throw new NotImplementedException();
        }
    }
}
